﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Collections;

namespace B2B.Models
{
    public class SP_MessageDetail
    {
        int maEmail;

        public int MaEmail
        {
            get { return maEmail; }
            set { maEmail = value; }
        }
        string emailNGuoiGui;

        public string EmailNGuoiGui
        {
            get { return emailNGuoiGui; }
            set { emailNGuoiGui = value; }
        }
        string emailNguoiNhan;

        public string EmailNguoiNhan
        {
            get { return emailNguoiNhan; }
            set { emailNguoiNhan = value; }
        }
        string chuDe;

        public string ChuDe
        {
            get { return chuDe; }
            set { chuDe = value; }
        }
        string noiDung;

        public string NoiDung
        {
            get { return noiDung; }
            set { noiDung = value; }
        }
        string hinhAnhSanPham;

        public string HinhAnhSanPham
        {
            get { return hinhAnhSanPham; }
            set { hinhAnhSanPham = value; }
        }
        string link;

        public string Link
        {
            get { return link; }
            set { link = value; }
        }
        string ngayGui;

        public string NgayGui
        {
            get { return ngayGui; }
            set { ngayGui = value; }
        }
        string hinhAnh;

        public string HinhAnh
        {
            get { return hinhAnh; }
            set { hinhAnh = value; }
        }

        public SP_MessageDetail messageDetail(int maEmail)
        {
            SP_MessageDetail sp_messageDetail = new SP_MessageDetail();
            SqlConnection conn = KetNoi.Connection();
            SqlCommand cmd = new SqlCommand("SP_CHITIETEMAIL", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MAEMAIL", maEmail);
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                sp_messageDetail.maEmail = reader.GetInt32(0);
                sp_messageDetail.EmailNGuoiGui = reader.GetString(1);
                sp_messageDetail.EmailNguoiNhan = reader.GetString(2);
                sp_messageDetail.ChuDe = reader.GetString(3);
                sp_messageDetail.NoiDung = reader.GetString(4);
                sp_messageDetail.HinhAnhSanPham = reader.GetString(5);
                sp_messageDetail.Link = reader.GetString(6);
                sp_messageDetail.NgayGui = reader.GetDateTime(7).ToShortDateString();
                sp_messageDetail.HinhAnh = reader.GetString(8).ToString();
            }
            conn.Close();
            return sp_messageDetail;
        }
    }
}